package com.bondar.RestLogin.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.bondar.RestLogin.entities.User;
import com.bondar.RestLogin.services.UserService;

@RestController
@RequestMapping("/user")
public class UserController {
	
	@Autowired UserService userService;
	
	@PreAuthorize(value="hasRole('ROLE_USER')")
	@RequestMapping(value = "/", method=RequestMethod.GET)
	public @ResponseBody List<User> getAllUsers() {
		System.out.println("get all user");
		return userService.findAll();
	}
	
}
